function main0401

clc;clear all;close all;
HiddenUnitNum=75;
dataset = load('dataset.mat');  
BP1 = struct2cell(dataset);
dataset1 = cell2mat(BP1);
Theta = load('Theta.mat');
BP2 = struct2cell(Theta);
Theta1 = cell2mat(BP2);
IN=double(dataset1(1:6,1:2:7000));
OUT=double(Theta1(1:6,1:2:7000));
p=IN;  
t=OUT;   
[pn,input_str] = mapminmax(p) ;
[tn,output_str] = mapminmax(t) ;
TrainSamIn=pn;
TrainSamOut=tn;
[xxx1,TrainSamNum]=size(TrainSamIn);
[xxx2,TrainSamNum]=size(TrainSamOut);

[NewW1,NewB1,NewW2,NewB2]=PSO_GATrain(TrainSamIn,TrainSamOut,HiddenUnitNum);
net=newff(minmax(pn),[HiddenUnitNum 6],{'logsig','purelin'},'trainlm');
net.trainParam.show=10;
net.trainParam.lr=0.01; 
net.trainParam.epochs=50000;
net.trainParam.goal=10^(-4);  
net.divideFcn = '';
net.iw{1,1}=NewW1;
net.b{1}=NewB1;
net.lw{2,1}=NewW2;
net.b{2}=NewB2;
net=train(net,pn,tn);
net.iw{1,1};
net.b{1};
net.lw{2,1};
net.b{2};

INtest=dataset1(1:6,2:2:1000);
OUTtest=Theta1(1:6,2:2:1000);
ptest=INtest;
ttest=OUTtest;
[pntest,input_str] = mapminmax(ptest) ;
[tntest,output_str] = mapminmax(ttest) ;
antest=sim(net,pntest);
a = mapminmax('reverse',antest,output_str);
[xxx,Ntest]=size(OUTtest);
Etheta1=sum((a(1,:)-ttest(1,:)).^2,2);                                     
Etheta2=sum((a(2,:)-ttest(2,:)).^2,2); 
Etheta3=sum((a(3,:)-ttest(3,:)).^2,2);
Etheta4=sum((a(4,:)-ttest(4,:)).^2,2);
Etheta5=sum((a(5,:)-ttest(5,:)).^2,2);
Etheta6=sum((a(6,:)-ttest(6,:)).^2,2);
(Etheta1/700)^0.5;
(Etheta2/700)^0.5;
(Etheta3/700)^0.5;
(Etheta4/700)^0.5;
(Etheta5/700)^0.5;
(Etheta6/700)^0.5;

